<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vue-router.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<router-link to="/page1">网页1</router-link>
			<router-link to="/page2">网页2</router-link>
			<router-link to="/page3">网页3</router-link>
			<router-view></router-view>
		</div>
	</body>
</html>
<script>
	var page1 = {
		template:'<h1>我是第一个网页</h1>'
	}
	
	var page2 = {
		template:'<h1>我是第二个网页</h1>'
	}
	
	var page3 = {
		template:`<div>
					<h1>我是第三个网页</h1>
					<button @click='gotopage1'>跳转到第一个网页</button>
				</div>`,
		methods:{
			gotopage1(){
				this.$router.push('/page1');
			}
		}
	}
	
	var router = new VueRouter({
		routes:[
			{
				path:'/page1',
				component:page1
			},
			{
				path:'/page2',
				component:page2
			},
			{
				path:'/page3',
				component:page3
			}
		]
	})
	
	var vm = new Vue({
		el:"#app",
		router
	})
</script>
